<?php

namespace app\admin\model\sales;

use think\Model;

/**
 * Salesorders
 */
class Salesorders extends Model
{
    // 表主键
    protected $pk = 'orderno';
    
    // 表名
    protected $name = 'sales_salesorders';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;


    public function debtornoTable(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\sales\Debtorsmaster::class, 'debtorno', 'debtorno');
    }

    public function branchcodeTable(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\sales\Custbranch::class, 'branchcode', 'branchcode');
    }

    public function shipviaTable(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\sales\Shippers::class, 'shipvia', 'shipper_id');
    }

    public function fromstklocTable(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\stock\Locations::class, 'fromstkloc', 'loccode');
    }

    public function salespersonTable(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\sales\Salesman::class, 'salesperson', 'salesmanname');
    }
}